package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"market/api/internal/config"
	"market/api/internal/middleware"
	"market/marketrpc/marketrpcclient"
)

type ServiceContext struct {
	Config              config.Config
	MarketRpc           marketrpcclient.Marketrpc
	UserLoginMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		MarketRpc:           marketrpcclient.NewMarketrpc(zrpc.MustNewClient(c.MarketRpc)),
		UserLoginMiddleware: middleware.NewUserLoginMiddleware().Handle,
	}
}
